import entity.AdminEntity;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;
import org.logicalcobwebs.proxool.admin.Admin;
import util.HibernateSessionFactory;

public class Main {

    public static void main(String[] args) {
        //select one
        Session session = HibernateSessionFactory.getSession();
        session.getTransaction();
        AdminEntity adminEntity = null;
        try {
            adminEntity = (AdminEntity) session.get(AdminEntity.class, 1);
        } catch (HibernateException e) {
            e.printStackTrace();
        }finally {
        }
        System.out.println(adminEntity);
        //save one
        AdminEntity adminEntity1 = new AdminEntity();
        adminEntity1.setUsername("ceshi2");
        adminEntity1.setPassword("cheshi");
        adminEntity1.setSysid(2);
        session.save(adminEntity1);
        Transaction transaction = session.getTransaction();
        transaction.commit();
        session.close();
    }

}
